<script lang="ts" setup>
  import { CourseItem } from '@/types/course';
  import { api as viewerApi } from 'v-viewer';

  defineProps<{
    courseInfo: CourseItem;
  }>();

  const previewImage = (url: string) => {
    viewerApi({
      images: [url],
      options: {
        navbar: false,
      },
    });
  };
</script>

<template>
  <div class="course-card">
    <div class="course-card-icon">
      <img :src="courseInfo.logo" @click="previewImage(courseInfo.logo)" />
    </div>
    <div class="course-card-info">
      <div class="course-card-name">
        <div class="course-card-name-c">
          {{ courseInfo.name }}
        </div>
      </div>
    </div>
  </div>
</template>

<style lang="less" scoped>
  .course-card {
    display: flex;
    align-items: center;
    &-icon {
      width: 60px;
      height: 60px;
      display: flex;
      align-items: center;
      justify-content: center;
      background: rgb(var(--gray-2));
      img {
        max-width: 100%;
        max-height: 100%;
      }
    }

    &-info {
      flex: 1;
      min-width: 0;
      margin-left: 10px;
    }

    &-name {
      font-size: 15px;
      font-weight: 500;
      display: flex;

      &-c {
        flex: 1;
      }
    }

    &-desc {
      color: var(--color-text-2);
    }
  }
</style>
